#ifndef OPENGL_UTIL_H_
#define OPENGL_UTIL_H_

#include<gl/GLU.h>
#include<gl/GL.h>
#include<QOpenGLFunctions>
static GLvoid PrintVersion()
{
    const GLubyte* name = glGetString(GL_VENDOR);            //返回负责当前OpenGL实现厂商的名字
    const GLubyte* biaoshifu = glGetString(GL_RENDERER);    //返回一个渲染器标识符，通常是个硬件平台
    const GLubyte* OpenGLVersion = glGetString(GL_VERSION);    //返回当前OpenGL实现的版本号
    const GLubyte* glsl = glGetString(GL_SHADING_LANGUAGE_VERSION);//返回着色预压编译器版本号
    const GLubyte* gluVersion = gluGetString(GLU_VERSION);    //返回当前GLU工具库版本
    printf("OpenGL Menufactor: %s\n", name);
    printf("OpenGL Render: %s\n", biaoshifu);
    printf("OpenGL Version: %s\n", OpenGLVersion);
    printf("OpenGL Shader Language Version: %s\n", glsl);
    printf("GLUT Tool Version: %s\n", gluVersion);
}

static void PrintGLSetting()
{
	bool b = glIsEnabled(GL_COLOR_MATERIAL);
	qDebug() << "GL_COLOR_MATERIAL: " << b;
}

// 测试最大buffer大小
static void TestMaxGLBufferData(QOpenGLFunctions* f)
{
	//glewInit();

#ifdef _WIN64
	printf("WIN64 mode: \n");
#else
	printf("WIN32 mode: \n");
#endif

	long long nNumberM = 0;
	// 限制一个数目，防止程序异常不能跳出(联想 T530 ) [12/2/2016 ZOSH];
	const long long MAX_NUMBER = 10000;
	while (glGetError() == GL_NO_ERROR && nNumberM < MAX_NUMBER)
	{
		GLuint objectVBO = 0;
		f->glGenBuffers(1, &objectVBO);
		f->glBindBuffer(GL_ARRAY_BUFFER, objectVBO);
		// 1<<20 = 1M 的空间;
		f->glBufferData(GL_ARRAY_BUFFER, 1 << 20, NULL, GL_STATIC_DRAW);
		nNumberM++;
	}

	printf("gpu  max size: %lld M,  (x, y, z):%lld \n", nNumberM, nNumberM * 1024 * (1024 / 12));
	printf("test end!!!\n");
}

#endif